﻿using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

namespace BCGPSCommon
{
    public static class GeneralContainer
    {
        /// <summary>
        /// 全局服务-提供接口对象
        /// </summary>
        public static IServiceProvider serviceProvider { set; get; }

        /// <summary>
        /// 全局配置
        /// </summary>
        public static IConfiguration configuration { set; get; }

        /// <summary>
        /// Redis命名空间  企业账户(公司Id) > vehicleNo >  车辆   
        /// </summary>
        public static string RedisNameSpaceAccountVehicle { set; get; }

        /// <summary>
        /// Redis命名空间     个人账户(手机号) >  vehicleNo > 车辆  
        /// </summary>
        public static string RedisNameSpaceAccountVehiclePerson { set; get; }

        /// <summary>
        /// Redis命名空间   IMEI > 位置 
        /// </summary>
        public static string RedisNameSpaceIMEILocation { set; get; }

        /// <summary>
        /// Redis命名空间   IMEI > CompanyId/AccountId > 报警    
        /// </summary>
        public static string RedisNameSpaceIMEIAlarm{ set; get; }

        /// <summary>
        /// Redis命名空间   CompanyId/AccountId > 账户 
        /// </summary>
        public static string RedisNameSpaceAccount { set; get; }

        /// <summary>
        /// Redis命名空间   IMEI> 待发送命令
        /// </summary>
        public static string RedisNameSpaceIMEISendCmd { set; get; }

        /// <summary>
        /// Redis命名空间   IMEI > 设备信息
        /// </summary>
        public static string RedisNameSpaceIMEIDevice { set; get; }

        /// <summary>
        /// Redis命名空间  CompanyId > 转发服务运行状态
        /// </summary>
        public static string RedisNameSpaceRelayControl { set; get; }

        /// <summary>
        /// 启用 -- GPS数据有效性统计
        /// </summary>
        public static bool IsUseGpsDataValidCount { set; get; }

        /// <summary>
        /// 4.2V电池报警电压
        /// </summary>
        public static float Bat42LowPowerAlarmVoltage { set; get; }

        /// <summary>
        /// 3V电池报警电压
        /// </summary>
        public static float Bat30LowPowerAlarmVoltage { set; get; }



        /// <summary>
        /// json格式设置
        /// </summary>
        public static JsonSerializerSettings JsonSerializerSettings { get; private set; } = new JsonSerializerSettings
        {
            ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy { ProcessDictionaryKeys = false } },
            Converters = new List<JsonConverter> {
                new StringEnumConverter { AllowIntegerValues = true },
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeLocal, DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }
            },
            NullValueHandling = NullValueHandling.Ignore
        };


    }
}
